//
//  SynDetailsFirstCell.m
//  XDBaseFrameWork
//
//  Created by XD-XY on 10/20/14.
//  Copyright (c) 2014 XD-XY. All rights reserved.
//

#import "SynDetailsFirstCell.h"

@implementation SynDetailsFirstCell

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        // Initialization code
        [self makeViews];
    }
    return self;
}

-(void)makeViews
{
    fArray = @[@"服装造型",@"拍摄张数",@"调修张数",@"底片",@"相册",@"相框",@"服务时长"];
    for (int i = 0 ; i <7;i++){ //47+7+13+4+16 = 47+20+20
        UIImageView * iv = [UIImageView initImageViewRect:CGRectMake(32*(i%4)+18+47*(i%4), 14+90*(i/4), 47, 47) andImage:nil andUserInteractionEnabled:YES];
        iv.backgroundColor =UIColorFromRGB(0xdcdcdc);
        iv.image = [UIImage imageNamed:[NSString stringWithFormat:@"zonghe_image0%d",i+1]];
        iv.tag = 3000+i;
        [self.contentView addSubview:iv];
        iv.layer.masksToBounds = YES;
        iv.layer.cornerRadius = 47/2.0f;
        
        UILabel * lb = [UILabel initLabelText:[fArray objectAtIndex:i] andRect:CGRectMake(iv.center.x-18-23.5,height_y(iv)+7,18+47+18, 13) andBackGroudColor:mClearColor andTextFont:[UIFont systemFontOfSize:12] andTextColor:UIColorFromRGB(0x929292) andTextAlignment:NSTextAlignmentCenter];
        lb.tag = 4000+i;
        [self.contentView addSubview:lb];
        
        
        UILabel * lb2 = [UILabel initLabelText:@"" andRect:CGRectMake(iv.center.x-18-23.5,height_y(lb)+3, 18+47+18, 16) andBackGroudColor:mClearColor andTextFont:[UIFont systemFontOfSize:13] andTextColor:UIColorFromRGB(0x8a8a8a) andTextAlignment:NSTextAlignmentCenter];
        lb2.tag = 5000+i;
        [self.contentView addSubview:lb2];
        
        UIButton * btn = [UIButton initButton:CGRectMake(iv.frame.origin.x, iv.frame.origin.y, 18+47, 80) btnImage:nil btnTitle:nil];
        [btn addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
        btn.tag = 6000+i;

        [self.contentView addSubview:btn];
    }
    

    self.upline = [UIImageView initImageViewRect:CGRectMake(0,0, UI_SCREEN_WIDTH-0, 0.5) andImage:LOADIMAGE(@"xuxian_short@2x") andUserInteractionEnabled:YES];
    [self.contentView addSubview:_upline];
    
    self.downline = [UIImageView initImageViewRect:CGRectMake(0,199.5, UI_SCREEN_WIDTH-0, 0.5) andImage:LOADIMAGE(@"xuxian_short@2x") andUserInteractionEnabled:YES];
    [self.contentView addSubview:_downline];
    
    self.realyPrice = [UILabel initLabelText:@"" andRect:CGRectMake(10, height_y(_downline),UI_SCREEN_WIDTH-10,33) andBackGroudColor:mClearColor andTextFont:[UIFont systemFontOfSize:20.0f] andTextColor:UIColorFromRGB(0xff6000) andTextAlignment:NSTextAlignmentLeft];
    [self.contentView addSubview:_realyPrice];
    
    CGRect rect = [XDTools autoSizeOftext:_realyPrice.text andSize:CGSizeMake(200, 20.0f) andtextFont:20.0f];
    
    self.makectPrice = [UILabel initLabelText:@"" andRect:CGRectMake(rect.size.width+15,_realyPrice.frame.origin.y+7, 150,23) andBackGroudColor:mClearColor andTextFont:[UIFont systemFontOfSize:12.0f] andTextColor:UIColorFromRGB(0x929292) andTextAlignment:NSTextAlignmentLeft];
    [self.contentView addSubview:_makectPrice];

    CGRect rect2 = [XDTools autoSizeOftext:_makectPrice.text andSize:CGSizeMake(200, 14.0f) andtextFont:12.0f];
    
    lview = [UIView initViewRect:CGRectMake(self.makectPrice.frame.origin.x,height_y(_makectPrice)-12.5, rect2.size.width+4, 1) andBackGroudColor:UIColorFromRGB(0x929292)];
    [self.contentView addSubview:lview];
}

- (void)hideSomeViews{
    _realyPrice.hidden = YES;
    _makectPrice.hidden = YES;
    lview.hidden = YES;
}

-(void)setDataDict:(NSMutableDictionary *)dataDict
{
    if (_type) {
        [self hideSomeViews];
    }
    if(![[dataDict allKeys] count]){
        return;
    }
    if(_dataDict){
        _dataDict = nil;
    }
    _dataDict = [[NSMutableDictionary alloc] initWithDictionary:dataDict];
    
    self.realyPrice.text = [NSString stringWithFormat:@"￥%@",_dataDict[@"Price"]];
    self.makectPrice.text = [NSString stringWithFormat:@"￥%@",_dataDict[@"MarketPrice"]];
    
    CGRect rect = [XDTools autoSizeOftext:_realyPrice.text andSize:CGSizeMake(200, 20.0f) andtextFont:20.0f];
    _makectPrice.frame =CGRectMake(rect.size.width+15,_realyPrice.frame.origin.y+7, 150,23);
    CGRect rect2 = [XDTools autoSizeOftext:_makectPrice.text andSize:CGSizeMake(200, 14.0f) andtextFont:12.0f];
    lview.frame = CGRectMake(self.makectPrice.frame.origin.x,height_y(_makectPrice)-12.5, rect2.size.width+4, 1);
    
    
    UILabel * lb1 =(UILabel *) [self viewWithTag:5000];
    UILabel * lb2 =(UILabel *) [self viewWithTag:5001];
    UILabel * lb3 =(UILabel *) [self viewWithTag:5002];
    UILabel * lb4 =(UILabel *) [self viewWithTag:5003];
    UILabel * lb5 =(UILabel *) [self viewWithTag:5004];
    UILabel * lb6 =(UILabel *) [self viewWithTag:5005];
    UILabel * lb7 =(UILabel *) [self viewWithTag:5006];
    
    lb1.text = [NSString stringWithFormat:@"%@组",_dataDict[@"ModeCount"]];
    lb2.text = [NSString stringWithFormat:@"%@张",_dataDict[@"ShootCount"]];
    lb3.text = [NSString stringWithFormat:@"%@张",_dataDict[@"RepairCount"]];
    lb4.text = [NSString stringWithFormat:@"%@张",_dataDict[@"PhotoCount"]];
    lb5.text = _dataDict[@"XCName"];
    lb6.text = _dataDict[@"XKName"];
    
    if([_dataDict[@"PhotoCount"] isEqualToString:@"底片全送"]){
        lb4.text = [NSString stringWithFormat:@"%@",_dataDict[@"PhotoCount"]];
    }else{
        lb4.text = [NSString stringWithFormat:@"%@张",_dataDict[@"PhotoCount"]];
    }
    lb7.text = [NSString stringWithFormat:@"%@分钟",_dataDict[@"SCount"]];
    
}


-(void)btnClick:(UIButton *)button
{
    [_delegate iconIvClickWithUrl:[NSString stringWithFormat:@"ulrstring%d",button.tag-6000]];
}



- (void)awakeFromNib
{
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
